// Unit Templates Hierarchy
// Advancement Project
// Jeremy Daugherty



/*
  a description of the unit family tree
  unit->\
        |-> Diplomat
        |-> Trader
        |-> Soldier
        |-> Armor
        |-> Aerial
        |-> Ship->\
                  |->SuperShip
        
  Unit- is the basic unit, that holds all other classes as children
  a virtual class
  
  Diplomat - This unit is a class that is used to create connections
  and communicate officially with other empires, the more experienced
  the better the effects. Also works a little slower than private
  communication but The People like to know where they're going.
  
  Trader - Traders are units that assist with trade, they are used to
  set up trade routes, if they are possible, as well as create supply
  chains to developing parts of you empire or military groups. They
  don't work as well as private trade, which does everything in the most
  efficient way and is more profitable to your empire, but it gives you
  a better control of the trade route, and lets you go to out of the
  way places that other traders may not go. Also, these can be fully 
  protected by soldiers. Rather than simply patroled
  
  Soldier - Soldiers are basic military units, they are defined by a
  name that defines marks them as a specific type of soldier. Each has
  a list of options that allow for the calculated data to change and
  add effects. The specific type is created by a template that is saved
  elsewhere.
  
  Armor - This is a unit that holds Soldiers, the experience is based on
  the sum of the operator's experience. The armor gonerally has a higher
  supply rate, and it also has a limited distance to which it can travel
  it needs to be resupplied after a certain time has passed. else it
  can't move. They don't have to return to base to be resupplied, and they
  won't die if they run out of fuel. Like all vehicles they can also carry
  a small group of non-essential personel. Soldiers in the vehicle have a 
  chance of surviving and can move to other armors.
  Operators are marked specially at the end of their name and cannot use
  other vehicles
  
  Aerial - This unit is very similar to Armor, but it moves much faster, 
  has a much larger range, and is much more fragile. It also MUST return
  to a base, otherwise it will crash and be lost. The pilot may survive,
  but you still lost a Fighter from stupidity. There are options that
  allow for mid-air refueling, but they must follow the same rules.
  
  Ship - Ships are very different from other vehicles. Ships, unlike
  other vehicles share their supply with their Flotilla, if one ship
  runs low on supply, all others compensate. This goes for fuel and food. 
  Ships can also supply non-ship units and groups, acting as a mobile
  base platform. The supplies they can hold are massive and can last
  months. They also can hold every other type of unit. (space ships can
  even hold other ships) They also have a much slower rate of movement
  compared to other units, but hold many times more other units than
  other units. Also, instead of suffering either complete ability use, 
  they simply slow down overall effectiveness without necissary personel.
  
  SuperShip - This is a peculiar class of ship that can be made to have a
  full colony capacity. This is for the super Titans and space stations.
  For best representation look at the Death Star from Star Wars. Now, it can 
  be even larger, stopping at planet sized ships for nomadic Space races of
  extreme technological calibur. These are ships large enough to have their
  own gravity well and stop at about a planet, where the concept of nuptune
  size object being moved becomes truly too extreme (besides I need an upper
  limit to the system somewhere).
*/


// the basic unit, used for nothing by itself. A virtual class
class unit
{
  protected:
    // the health of the unit, all units have this
    int m_health;
  
    // the max speed the unit can move
    float m_speed;
    
    // the armor of the unit or damage resistance
    int m_damRes;
  
    // the type, random id, and the team is stored here to allow easy access.
    const char m_ID[20];
    
    // the ammount of experience, calculated differently for all derivatives;
    float m_exp;
    
    // The object it is connected to.
    star *m_system; 
    // if null, then it is in the galactic map or in another unit
    unit *m_transport;
    // if this and system is null then it is in the galactic map. If this
    // transport unit is destroyed the unit is lost as well.
    
    
    // coordinates of the object in a system
    struct coord
    {
      float x;
      float y;
      float z;
    } m_location;
    
    // Model of the object, 2D for single units, 3D for more complex
    // Model
};

class diplomat: public unit
{
  private:
    // the specific name of the diplomat.
    std::string m_name;
    
    // damage resistance is set to zero, health to one
    // this unit enters into political buildings
    // always use the fastest path.
};

class trader: public unit
{
  private:
    // The route they will follow.
    // coors series
    // they always pick the fastest path
    // generally defenceless
    
    // the ammount of things it can carry
    int m_capacity;
    
};

class soldier: public unit
{
  private:
    // the ammount of damage done per hit.
    int m_strength;

    // the max range
    int m_range;
    
    // the chance of hitting and doing damage dependant on the range
    float m_hitRatio;
  
    // the ID also holds any special traits such as medic or 
    // operator status
    
    // the modifier for attacking armors
    float m_Varmor; // damage
    float m_VarmorRange; // range
    float m_VarmorHit; // hit ratio
    
    // modifier for Aerials
    float m_Vaerial; // damage
    float m_VaerialRange; // range
    float m_VaerialHit; // hit ratio
};

class armor: public unit
{
  private:
    // the damage per hit
    int m_strength;
    
    // the range of attack
    int m_range;
    
    // the hit ratio
    float m_hitRatio;
    
    // max runtime or fuel capacity
    // some time unit
    
    // the weight of the unit that limits the transportation
    int m_mass;
    
    // total number of men that can be held
    int m_capacity;
    
    // modifier for soldiers
    float m_Vsoldier; // damage
    float m_VsoldierRange; // range
    float m_VsoldierHit; // hit ratio
    
    // modifier for Aerials
    float m_Vaerial; // damage
    float m_VaerialRange; // range
    float m_VaerialHit; // hit ratio
    
};

class aerial: public unit
{
  private:
    // the minimum speed that must be maintained
    int m_minSpeed;
    
    // the damage per hit
    int m_strength;
    
    // the range of attack
    int m_range;
    
    // the hit ratio
    int m_hitRatio;
    
    // max runtime fuel capacity
    // some time unit
    
    // transportation capacity in terms of men
    int m_capacity;
    
    // does it work in the atmosphere
    bool m_aerial;
    
    // does it work in space
    bool m_stellar;
    
    // modifiers for soldiers
    float m_Vsoldier; // damage
    float m_VsoldierRange; // range
    float m_VsoldierHit; // hit ratio
    
    // the modifier for attacking armors
    float m_Varmor; // damage
    float m_VarmorRange; // range
    float m_VarmorHit; // hit ratio
    
    // modifiels for attacking ships and superships
    float m_Vship; // damage
    float m_VshipRange; // range
    float m_VshipHit; // hit ratio
}

class ship: public unit
{
  private:
    // strength
    int m_strength;
    
    // range
    int m_range;
};

// class SuperShip: public unit




// the unit tree system. Can hold ten of a unit type and treat them 
// as a single unit. The higher the level of zoom, the larger the
// unit tree shown

// May be altered, based on visualizations.

/*
  Unit trees are based on a recursive tree structure. A Tree can hold ten
  units, or ten SubTrees. The max tree stack that I will probably allow is 
  seven which would hold 10^7 units (ten million). 
*/

template <class T>
class UnitTree
{
  private:
    // The level of the group in a name.
    std::string m_title;
    
    // the name of the group, generic unless changed.
    std::string m_name; 
    
    // the sum of the health of the units
    unsigned long int m_health;
    
    // the total number of units in the class    
    unsigned long int m_size;
    
    // a number between 1 and 10 that says the total occupied slots
    short m_slots; 

    // The number of trees beneath it.
    short m_level;
    
    // the container that holds all things below it.
    // not sure if I should use list or vector object. 
};

/*

misc Ideas

  Units

All individual units are merely healthbars and pointers to their template.

A unit that is connected to an obsolete template will eventually find it's
way to a barracks or other military station and be upgraded at a time cost.

As long as there is one unit using a template the template will continue to
exist (having a list of all current units of that template). Once the
obsolete template has no remaining units it will be deleted, possibly
coppied over to ensure tight storage in the storage structure.

  Warfare
  
War requires a number of things in at least minimum values to continue.

Men to fight the war, the hardest thing to run out of. 
Units to use or create (generally the hardest to lose so long as you have
the  population).

Materiel to feed and keep your men fighting.
That means mostly food and fuel, but easily extends to resourses to create
weapons. Without this Morale falls, men starve.

Morale to keep pushing forward, even in the face of death.
The not necissarily the momentum of the army so much as the will to continue.
The morale or will of the people to support the war ultimately can crush the 
war without fighting.

Control in both military and political fields to maintain cohesiveness.
Without the empire or its leaders you suffer a political loss, this is
beside resourses as the loss of this generally means the loss of land to
support your army, however so long as leadership remains you can continue on.

The only two things that are absolutely required to continue are men and
control. No men means no army, and an army without control is simply a mob.

Materiel can be overcome through dirty tactics and scavanging for what is
needed.

Civilian Morale is only needed if your people ultimately have control.

  Great People
  
Great people are similar to the great people of Civilization, but work
differently from them. Where Civ was mostly a one off unit, these aren't used.
Great people act continuously, they become the seeds or cores of different 
branches of your empire. 

Great engineers may become the heart of construction and production to your
empire, they give boosts to the quality that can be produced, how cheap it is 
to produce, or how quickly they can be produced. They make improvements to
current systems and improve tertiary techs faster than scientists, but research
primary and secondary slower. If they are lost you will not lose their
improvements.

Great Scientists generally speciallize in certain fields, giving a boost to
research in that area (multiple can be used). They work on techs alone, but are
faster on primary and secondary.

Great Generals or Admirals help lead the military and raise the general
skill level of an army or navy respectfully.

Great Prophets are used by religions and are tied to them as such, they help 
spread the religion and also define the religious beliefs. 

Great Leaders (not politicians) are other potential leaders who may or may not 
challenge you (your current avatar) as leader. They can reinforce or destroy 
your avatar as the leader, help with diplamacy, support or denounce the war.
Consider them the secondary AI of your empire that will have a mind of it's own.
They can also become your next \ replacement avatar.

Great Soldiers (better called Heroes) are especially powerful units that bolster
morale, and become softer spearheads. They're loss can either lower morale or
bolster it, depending on what they say to the people, but lost experience can be
guaranteed.
Heroes can be soldiers or operators. Armor operators work in groups. Pilots
become Aces. There are no heroes in ships, ships have no such rank, but there is
the designations of capitol ships (size based) and flagships (a desigation of 
importance and command).

All great people will have a general effect in raising the total level in their
area, and improving the general experience. When they are lost their experience
is also lost as is the boosted learning rate. With teaching methods such as 
apprenticeship or schooling the learning rate and allow for an heir to the
position, allowing a lesser loss of experience and a replacement to be faster
coming.

There are no great artists, the overall empire defines that.


*/